/**
 * 
 */
package server;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import java.util.Vector;

/**
 * UserManager
 * 	Manages Users and their Notifications
 * 	Differs between Online and Offline Users
 * 
 * @author Fleischhacker
 *
 */
public class UserManager{
	
	private Vector<User> users;
	
	public UserManager(){
		users = new Vector<User>();
	}
	
	/**
	 * adds an User to the Manager
	 * @param _user
	 */
	public void addUser(User _user){
		synchronized(this){
			users.add(_user);
		}
	}
	
	/**
	 * Returns User by Screenname
	 * @param _screenanme
	 * @return
	 */
	public User getUserByScreenname(String _screenanme){
		for(User u : users){
			if(u.getUsername().equals(_screenanme)){
				return u;
			}
		}
		return null;
	}
	
	/**
	 * Returns a List of the Users
	 * @return
	 */
	public List<User> listUsers(){
		ArrayList<User> list = new ArrayList<User>();
		for (User u : users){
			list.add(u);
		}
		return list;
	}
}
